/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package rest.pojo.conversor;

import entidade.Rasa;
import java.util.ArrayList;
import java.util.List;
import rest.pojo.RasaPOJO;

/**
 *
 * @author geovane
 */
public class RasaConverter {

    private static final RasaConverter uniqueInstance = new RasaConverter();

    private RasaConverter() {

    }

    public static RasaConverter getInstance() {
        return uniqueInstance;
    }

    public static RasaPOJO toRasaPOJO(Rasa rasa) {

        if (rasa != null) {
            RasaPOJO resposta = new RasaPOJO();

            resposta.setId(rasa.getId());
            resposta.setCodigo(rasa.getCodigo());
            resposta.setComplemento(rasa.getComplemento());
            resposta.setPeso(rasa.getPeso());
            return resposta;

        } else {
            return null;
        }
    }

    public static Rasa fromRasaPOJO(RasaPOJO rasaPOJO) {
        if (rasaPOJO != null) {
            Rasa resposta = new Rasa();

            resposta.setId(rasaPOJO.getId());
            resposta.setCodigo(rasaPOJO.getCodigo());
            resposta.setComplemento(rasaPOJO.getComplemento());
            resposta.setPeso(rasaPOJO.getPeso());

            return resposta;

        } else {
            return null;
        }
    }

    public static List<RasaPOJO> toRasasPOJO(List<Rasa> rasas) {
        if (rasas != null) {

            ArrayList<RasaPOJO> resposta = new ArrayList<>();

            rasas.stream().forEach((rasa) -> {
                resposta.add(toRasaPOJO(rasa));
            });

            return resposta;
        } else {
            return null;
        }

    }

    public static List<Rasa> fromRasasPOJO(List<RasaPOJO> rasasPOJO) {
        if (rasasPOJO != null) {

            ArrayList<Rasa> resposta = new ArrayList<>();

            rasasPOJO.stream().forEach((rasaPOJO) -> {
                resposta.add(fromRasaPOJO(rasaPOJO));
            });

            return resposta;
        } else {
            return null;
        }
    }

}
